import styles from './login.css';
import { Form, Input, Button, Checkbox, message } from 'antd';
import axios from '../utils/index'
import { useState } from 'react';
import { UploadOutlined,ExclamationCircleOutlined,UserOutlined,KeyOutlined  } from '@ant-design/icons';;


export default function Login(props) {
    const [name,setname] = useState()
    const [password,setpassword]=useState()
    const onFinish1 = async (values) => {
        var res=await axios.post('login',{
            username:values.username,
            password:values.password
        })
        if(res.meta.status===200){
            message.success('登录成功')
            localStorage.setItem('token',res.data.token)
            props.history.push('/home/goodslist')
        }
    };
    const updname =(e)=>{
        setname(e.target.value)
    }
    const updpassword =(e)=>{
        setpassword(e.target.value)
    }
    return (
        <div className={styles.total}>
            <div className={styles.logindiv}>
                <Form
                    name="basic"
                    style={{marginTop:"65px"}}
                    labelCol={{ span: 10 }}
                    wrapperCol={{ span: 18 }}
                    // initialValues={{ remember: true }}
                    onFinish={onFinish1}
                    autoComplete="off"
                >
                    <Form.Item
                        name="username"
                        rules={[{ required: true, message: 'Please input your username!' }]}
                    >
                        <Input size="large" placeholder="请输入账号" prefix={<UserOutlined />} style={{marginLeft:"40px"}} />
                    </Form.Item>

                    <Form.Item
                        name="password"
                        rules={[{ required: true, message: 'Please input your password!' }]}
                    >
                        <Input.Password size="large" placeholder="请输入密码" prefix={<KeyOutlined  />} style={{marginLeft:"40px"}} />
                    </Form.Item>

                    <Form.Item wrapperCol={{ offset: 18, span: 16 }}>
                        <Button type="primary" htmlType="submit" style={{marginTop:"30px"}}>
                            登录
                        </Button>
                    </Form.Item>
                </Form>
            </div>
        </div>
    )
}